#!/bin/bash
set -e

HARBOR_VERSION=v1.8.2
CHARTMUSEUM_VERSION=v0.9.0-v1.8.2
HARBOR_REGISTRY_PHOTON_VERSION=v2.7.1-patch-2819-v1.8.2
CLAIR_PHOTON_VERSION=v2.0.8-v1.8.2
NOTARY_SERVER_PHOTON_VERSION=v0.6.1-v1.8.2

HARBOR_URL=goharbor
CUSTOM_URL=172.16.36.30/goharbor
 
harbor_images=(chartmuseum-photon:${CHARTMUSEUM_VERSION}
harbor-migrator:${HARBOR_VERSION}
redis-photon:${HARBOR_VERSION}
clair-photon:${CLAIR_PHOTON_VERSION}
notary-server-photon:${NOTARY_SERVER_PHOTON_VERSION}
notary-signer-photon:${NOTARY_SERVER_PHOTON_VERSION}
harbor-registryctl:${HARBOR_VERSION}
registry-photon:${HARBOR_REGISTRY_PHOTON_VERSION}
nginx-photon:${HARBOR_VERSION}
harbor-log:${HARBOR_VERSION}
harbor-jobservice:${HARBOR_VERSION}
harbor-core:${HARBOR_VERSION}
harbor-portal:${HARBOR_VERSION}
harbor-db:${HARBOR_VERSION}
prepare:${HARBOR_VERSION})


for imageName in ${harbor_images[@]} ; do
  # docker pull $CUSTOM_URL/$imageName
  # docker tag  $CUSTOM_URL/$imageName $HARBOR_URL/$imageName
  # docker rmi $CUSTOM_URL/$imageName
  docker pull $HARBOR_URL/$imageName
  docker tag  $HARBOR_URL/$imageName $CUSTOM_URL/$imageName
  docker push $CUSTOM_URL/$imageName
done

docker images